package com.fairytask.ui
{
	import com.fairytask.engine.components.button.Button;
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.define.TabBtnDefine;
	import com.fairytask.engine.define.UIDefine;
	import com.fairytask.resource.StaticIni;
	import com.fairytask.ui.base.BaseUI;
	import com.fairytask.ui.base.FrameUI;
	import com.fairytask.ui.mainUnit.RoleListUI;
	import com.fairytask.ui.mainUnit.UniverseUI;
	import com.fairytask.ui.pack.PackageUI;
	
	/**
	 * 背包/阵型 
	 * @author xujh
	 * 
	 */
	public class MainUI extends FrameUI
	{
		private static var _self		:MainUI;
		
		public var packageBg	:Clip;	//背包背景
		public var lineupBg	:Clip;	//阵型
		public var otherBg		:Clip;	//其他的
		
		private const CLIP_BG_X	:int = 0; 
		private const CLIP_BG_Y	:int = 10; 
		
		private var pageBtn	:Button;	//临时按钮
		
		public static function getInstance():MainUI
		{
			if (_self == null)
			{
				_self=new MainUI;
			}
			return _self;
		}
		
		public function MainUI(popUI:Boolean=true)
		{
			super(popUI);
			init();
		}
		
		/**
		 * 初始化 
		 * 
		 */
		private function init():void
		{
			RoleListUI.getInstance();
			
			_unitUI.soildUI	=	true;
			//背包
			pageBtn  = new Button(StaticIni.getSwfLangStr("1000000017"),60,25,"button_036");
			addButton(pageBtn);
			pageBtn  = new Button(StaticIni.getSwfLangStr("1000000018"),60,25,"button_036");
			pageBtn.enabled = false;
			addButton(pageBtn);
			pageBtn  = new Button(StaticIni.getSwfLangStr("1000000080"),60,25,"button_036"); 
			pageBtn.enabled = false;
			addButton(pageBtn);
			pageBtn  = new Button(StaticIni.getSwfLangStr("1000000079"),60,25,"button_036");
			pageBtn.enabled = false;
			addButton(pageBtn);
			pageBtn  = new Button(StaticIni.getSwfLangStr("1000000081"),60,25,"button_036");
			pageBtn.enabled = false;
			addButton(pageBtn);
			
			addShowUI([[UIDefine.RoleListUI],[UIDefine.PackageUI,330,20],[UIDefine.ProfileUI,70,0]],TabBtnDefine.PACKAGE,[packageBg,CLIP_BG_X,CLIP_BG_Y]);
			addShowUI([[UIDefine.LineupUI]],TabBtnDefine.LINEUP,[lineupBg,CLIP_BG_X,CLIP_BG_Y]);
			//升星
			addShowUI([[UIDefine.RoleListUI],[UIDefine.UniverseUI,330,20],[UIDefine.ProfileUI,70,0]],TabBtnDefine.UNIVERSE,[otherBg,CLIP_BG_X,CLIP_BG_Y]);
			//精炼
			addShowUI([[UIDefine.RoleListUI],[UIDefine.RefineUI,330,20],[UIDefine.ProfileUI,70,0]],TabBtnDefine.REFINE,[otherBg,CLIP_BG_X,CLIP_BG_Y]);
			//洗练
			addShowUI([[UIDefine.RoleListUI],[UIDefine.RecastUI,330,20],[UIDefine.ProfileUI,70,0]],TabBtnDefine.RECAST,[otherBg,CLIP_BG_X,CLIP_BG_Y]);
		}
		
		/**
		 * 重写显示内容，用来新手引导 
		 * @param pos
		 * 
		 */
		override public function showPos(pos:int):void
		{
			switch(pos)
			{
				case 0:
					_unitUI.currentUI	=	PackageUI.getInstance() as BaseUI;
					break;
				case 1:
					_unitUI.currentUI	=	PackageUI.getInstance() as BaseUI;
					break;
				case 2:
					_unitUI.currentUI	=	UniverseUI.getInstance() as BaseUI;
					break;
			}
			super.showPos(pos);
		}
	}
}